﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@{
    ViewBag.Title = "入厂采样分布率统计";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}

<table style="width:100%">
    <tbody>
        <tr>
            <td style="width:100%;vertical-align: top" colspan="2">
                <div class="mvctool">
                    @*@Html.DropDownList("SAMPLING_USER_ID", ViewBag.SAMPLING_USER_ID as SelectList, new { @style = "width:230px" })*@
                    <select class="easyui-combobox" name="MATERIEL_ID" id="MATERIEL_ID" style="width:150px;"></select>
                    <select class="easyui-combobox" name="SUPPLIER_ID" id="SUPPLIER_ID" style="width:250px;"></select>
                @*</div>
            </td>
        </tr>
        <tr>
            <td style="width:100%;vertical-align: top" colspan="2">
                <div class="mvctool">*@
                    @Html.DropDownList("StatisticalMethod", ViewBag.StatisticalMethod as SelectList, new { @style = "width:130px" })
                    <input id="SAMPLING_BEGIN_TIME" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', maxDate: '#F{$dp.$D(\'SAMPLING_END_TIME\')}' })" type="text" class="searchText" style="width:150px" placeholder="统计时间起" />
                    <input id="SAMPLING_END_TIME" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'SAMPLING_BEGIN_TIME\')}' })" type="text" class="searchText" style="width:150px" placeholder="统计时间止" />
                    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
                    @Html.ToolButton("btnExport", "fa fa-level-up", Resource.Export, ref perm, "Export", true)
                </div>
                <div>
                    <table id="ListParent"></table>
                </div>
            </td>
        </tr>
        <tr>
            <td style="vertical-align:top">
                <div id="main" style="height:400px"></div>
            </td>
        </tr>
    </tbody>
</table>
<script src="@Url.Content("~/Scripts/echarts.min.js")"></script>
<script src="@Url.Content("~/Scripts/echarts.theme.shine.js")"></script>
<script src="~/Scripts/common.js"></script>
<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'), "shine");
    $("#main").width($(window).width() - 10).height($(window).height() - (SetGridHeightSub(40) - SetGridHeightSub(110)));
    $(function () {
        $('#ListParent').datagrid({
            url: '@Url.Action("GetListParent")',
            width: SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(55) - SetGridHeightSub(120),
            fitColumns: true,
            sortName: 'SAMPLING_ID',
            sortOrder: 'desc',
            idField: 'SAMPLING_ID',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: false,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            rownumbers: true,//行号
            onLoadSuccess: function (data) {
                myChart.clear();
                var rows = $('#ListParent').datagrid("getRows");
                if (rows.length > 0) {
                    $('#ListParent').datagrid('selectRow', 0);//grid加载完成后自动选中第一行
                    var row = $('#ListParent').datagrid('getSelected');//获取选中的数据
                    myChart.setOption(row.option);
                }
            },
            columns: [[
                { field: 'BLOCK1', title: '块1', width: 70, sortable: true },
                { field: 'BLOCK2', title: '块2', width: 70, sortable: true },
                { field: 'BLOCK3', title: '块3', width: 70, sortable: true },
                { field: 'BLOCK4', title: '块4', width: 70, sortable: true },
                { field: 'BLOCK5', title: '块5', width: 70, sortable: true },
                { field: 'BLOCK6', title: '块6', width: 70, sortable: true },
                { field: 'BLOCK7', title: '块7', width: 70, sortable: true },
                { field: 'BLOCK8', title: '块8', width: 70, sortable: true },
                { field: 'BLOCK9', title: '块9', width: 70, sortable: true },
                { field: 'BLOCK10', title: '块10', width: 70, sortable: true },
                { field: 'BLOCK11', title: '块11', width: 70, sortable: true },
                { field: 'BLOCK12', title: '块12', width: 70, sortable: true },
                { field: 'BLOCK13', title: '块13', width: 70, sortable: true },
                { field: 'BLOCK14', title: '块14', width: 70, sortable: true },
                { field: 'BLOCK15', title: '块15', width: 70, sortable: true },
                { field: 'BLOCK16', title: '块16', width: 70, sortable: true },
                { field: 'BLOCK17', title: '块17', width: 70, sortable: true },
                { field: 'BLOCK18', title: '块18', width: 70, sortable: true },
                { field: 'option', title: 'option', width: 70, hidden: true }
            ]]
         ,onClickRow: function(index, row) {
             myChart.setOption(row.option);
         }
        }).datagrid('getPager');


         $(window).resize(function() {
             resizeLayout();
        });

    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }

    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        GetTranSuppList(0, "@ViewBag.SUPPLIER_ID");
        GetTranSuppList(2, "@ViewBag.MATERIEL_ID");

        $("#btnQuery").click(function () {
            var MATERIEL_ID = $('#MATERIEL_ID').combobox('getValues').toString();
            var SAMPLING_USER_ID = $("#SAMPLING_USER_ID").val();
            var SUPPLIER_ID = $('#SUPPLIER_ID').combobox('getValues').toString();
            var StatisticalMethod = $("#StatisticalMethod").val();
            var SAMPLING_BEGIN_TIME = $("#SAMPLING_BEGIN_TIME").val();
            var SAMPLING_END_TIME = $("#SAMPLING_END_TIME").val();

            $("#ListParent").datagrid("load", { MATERIEL_ID: MATERIEL_ID, SAMPLING_USER_ID: SAMPLING_USER_ID, SUPPLIER_ID: SUPPLIER_ID, StatisticalMethod: StatisticalMethod, SAMPLING_BEGIN_TIME: SAMPLING_BEGIN_TIME, SAMPLING_END_TIME: SAMPLING_END_TIME });

        });


    });

    function resizeLayout()
     {
         setTimeout(function () {
             $('#ListParent').datagrid('resize', {
             }).datagrid('resize', {
                 width: SetGridWidthSub(20),
                 height: SetGridHeightSub(40) - SetGridHeightSub(120),
             });
         },100);
	    }
</script>



